﻿{layout:default} {class:Shop.supplier.product.datainout}
<lbhead>
    <title>
        <%=Tag("数据导入导出")%>-<%=site.title%></title>
</lbhead>
<lbfile>
    <script type="text/javascript" src="<%=site.AdminJsPath %>/ajaxfileupload.js"></script>
    <style>
        .bottom{height: 0;overflow: hidden;display: none;}
    </style>
</lbfile>
<lbpath>
    <div class="tools">
        <ul>
            <li class="name"><span id="navIgation">
                <%=Tag("当前位置")%>：<a href="<%=site.AdminPath %>/Ajax/ajax_admin.aspx?__Action=MenuJump&pid=0"><%=Tag("管理首页")%></a>
                >
                <%=Tag("数据导入导出") %></span></li>
        </ul>
    </div>
</lbpath>
<lbbody>
    <div class="proBox clear">
        <ul class="btns clear">
            <li class="menu"><%=Tag("数据导入")%></li>
        </ul>
        <div class="iTabHead">
            <table
                id="common" class="table">
                <tbody>
                    <tr>
                        <th>
                            <%=Tag("导入分类")%>：
                        </th>
                        <td id="shopnick">
                            <select id="tb_typeid" name="tb_typeid">
                                <%=Shop.Bussiness.EX_Product.TypeOption(0,0,0,CurrentLanguage.Code)%>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <%=Tag("数据格式")%>：
                        </th>
                        <td>
                            <label><input type="radio" name="datatype" id="datatype" value="1" checked /><%=Tag("淘宝CSV")%></label>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <%=Tag("数据文件")%>：
                        </th>
                        <td>
                            <input type="text" shop="true" id="tb_file" name="tb_file" class="input" style="width: 300px;" value="" /> 
                            <input id="file_tb_file" name="file_tb_file" class="input" type="file" /> 
                            <input id="Button2" onclick="uploadFile('tb_file');" value="<%=Tag("上传") %>" class="button" type="button" />
                            <span id="status_tb_file"></span>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <%=Tag("图片文件夹")%>：
                        </th>
                        <td>
                            <input type="text" shop="true" id="tb_folder" name="tb_folder" class="input" style="width: 300px;" value="" />
                            <em>相对安装路径，以"/"开头和结尾</em>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <%=Tag("分隔符")%>：
                        </th>
                        <td>
                            <label><input type="radio" shop="true" name="tb_split" class="input" value="2" checked />逗号(,)</label>
                            <label><input type="radio" shop="true" name="tb_split" class="input" value="1" />制表符(/t)</label>
            
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <%=Tag("语言")%>：
                        </th>
                        <td>
                            <select id="tbin_lang" name="tbin_lang" shop="true">
                                <%=Shop.Bussiness.Language.LanguageOption(CurrentLanguage.Code)%>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>
                        </th>
                        <td>
                        <div class="tools tools-m clear">
                            <ul>
                                <li class="submit"><a href="javascript:void(0);" onclick="tb_product_in();"><b></b><span><%=Tag("提交")%></span></a></li>
                            </ul>
                        </div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="proBox clear">
        <ul class="btns clear">
            <li class="menu"><%=Tag("数据导出")%></li>
        </ul>
        <div class="iTabHead">
            <table
                id="Table1" class="table">
                <tbody>
                    <tr>
                        <th>
                            <%=Tag("导出范围")%>：
                        </th>
                        <td>
                            <a href="javascript:void(0);" onclick="SearchWindow();"><%=Tag("高级搜索")%></a>
                            <%=sp.Description%>
                            
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <%=Tag("数量")%>：
                        </th>
                        <td>
                            <%=Shop.Bussiness.B_Lebi_Product.Counts("Supplier_id =" + CurrentSupplier.id + " and Product_id=0 "+sp.SQL) %>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <%=Tag("语言")%>：
                        </th>
                        <td>
                            <select id="tb_lang" name="tb_lang">
                                <%=Shop.Bussiness.Language.LanguageOption(CurrentLanguage.Code)%>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <%=Tag("数据格式")%>：
                        </th>
                        <td>
                            <label><input type="radio" name="datatype2" id="datatype2" value="1" checked /><%=Tag("淘宝CSV")%></label>
                        </td>
                    </tr>
                    <tr id="tr_down" style="display:none">
                        <th>
                            <%=Tag("下载")%>：
                        </th>
                        <td id="down_url">
                            
                        </td>
                    </tr>
                    <tr>
                        <th>
                        </th>
                        <td>
                        <div class="tools tools-m clear">
                            <ul>
                                <li class="submit"><a href="javascript:void(0);" onclick="tb_product_out();"><b></b><span><%=Tag("提交")%></span></a></li>
                            </ul>
                        </div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <script type="text/javascript">
        function tb_product_in() {
            var tb_typeid = $("#tb_typeid").val();
            var tb_file = $("#tb_file").val();
            var tb_folder = $("#tb_folder").val();
            var tb_split=$("input[name='tb_split']:checked").val();
            var tbin_lang=$("#tbin_lang").val();
            var url = "<%=site.AdminPath %>/ajax/export.aspx?__Action=taobao_product_in";
            var postData = { "tb_typeid": tb_typeid, "tb_file": tb_file,"tb_folder":tb_folder,"tb_split":tb_split,"tbin_lang":tbin_lang };
            $.ajax({
                type: "POST",
                url: url,
                data: postData,
                dataType: 'json',
                beforeSend: function () {
                    MsgBox(4, "正在处理 ……", "-");
                },
                success: function (res) {
                    if (res.msg == "OK") {
                        MsgBox(1, "<%=Tag("操作成功") %>："+res.count, "");
                    }
                    else {
                        MsgBox(2, res.msg, "");
                        return false;
                    }
                }
            });
        }
        function SearchWindow() {
            var title_ = "<%=Tag("商品查询")%>";
            var url_ = "../product/product_search_window.aspx?callback=search_&<%=sp.URL %>";
            var width_ = 700;
            var height_ = 505;
            var modal_ = true;
            EditWindow(title_, url_, width_, height_, modal_);
        }
       function search_(scurl) {
            window.location = "?"+scurl;
       }

        function tb_product_out()
        {
           var lang=$("#tb_lang").val();
           var url = "<%=site.AdminPath %>/ajax/export.aspx?__Action=taobao_product_out&lang="+lang+"&<%=sp.URL %>"; 
           $.ajax({
                type: "POST",
                url: url,
                data: '',
                dataType: 'json',
                beforeSend: function () {
                    MsgBox(4, "<%=Tag("正在处理") %> ……", "-");
                },
                success: function (res) {
                    if (res.msg == "OK") {
                        $("#tr_down").show()
                        $("#down_url").html("<a href=\""+res.url+"\" target=\"_blank\">"+res.url+"</a>");
                        MsgBox(1, "<%=Tag("操作成功") %>", "");
                    }
                    else {
                        MsgBox(2, res.msg, "");
                        return false;
                    }
                }
            });
        }
    </script>
</lbbody>
<lbbottom>
    <input type="hidden" id="pwd" runat="server" />
</lbbottom>
